#include "main_framework.h"

extern uint8_t led_ls;
void task1_func()
{
    // hdl_screen_full_check();
    uint8_t i = 0;
    for(i=0;i<16;i++)
    {
        LED_MATRIX_COLNUMN_PORT->BRR = LED_MATRIX_COLNUMN_MR;
        hdl_colnumn_send_data(0xff);
        hdl_colnumn_send_data(0x00);
        hdl_colnumn_send_data(0xFF);
        hdl_colnumn_send_data(0xaa);

        LED_MATRIX_COLNUMN_PORT->BSRR = LED_MATRIX_COLNUMN_ST_CP;
        systick_delay_us(2);
        LED_MATRIX_COLNUMN_PORT->BRR = LED_MATRIX_COLNUMN_ST_CP;
        systick_delay_us(2);

        hdl_row_scan(i);
        LED_MATRIX_COLNUMN_PORT->BSRR = LED_MATRIX_COLNUMN_MR;
        if(led_ls == 1)
        {
            systick_delay_ms(10);
        }
        else
        {
            systick_delay_us(4);
        }
        
    }
}

void task2_func()
{
	hdl_SetIOGledToogle();
}

void task3_func()
{
    
}

void task4_func()
{	
	hdl_SetIORledToogle();
}


TASK_COMPONENTS TaskComps[] = 
{
    {0, 1, 1,       task1_func},
    {0, 100, 100,   task2_func},
    {0, 5, 5,       task3_func},
    {0, 1000, 1000, task4_func},
    //add new tasks,pls  here
};

void task_remark(void)
{
    uint8_t count = 0;
    for (count=0; count<CALCULATE_LEN(TaskComps); count++)
    {
        TaskComps[count].Timer--;
        if (TaskComps[count].Timer == 0)
        {
            TaskComps[count].Timer = TaskComps[count].ItvTime;
            TaskComps[count].TaskHook();
        }
        systick_delay_ms(1);
    }
}

void main_framework_interface(void)
{
    task_remark();
}
